unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, RzButton, Vcl.ExtCtrls, RzPanel,
  Vcl.StdCtrls, RzEdit,Dialog_View,System.SyncObjs, Vcl.Grids, AdvObj, BaseGrid,
  AdvGrid, RzSplit;

type
  TForm1 = class(TDialogView)
    Tool_1: TRzToolbar;
    Btnv_Call: TRzToolButton;
    Memo_Main: TRzMemo;
    Grid_1: TAdvStringGrid;
    RzSplitter1: TRzSplitter;
    procedure Btnv_CallClick(Sender: TObject);
  private
    FCSInData:TCriticalSection;//*
  protected
    procedure SetInitialize;override;
    procedure SetCommParams;override;
    procedure SetGridParams;override;
    procedure SetComboItems;override;
    procedure TryFreeAndNil;override;
  public
    procedure CallThradWakeDemo(aDemoIndx:Integer);
  public
    //for tkzthrad
    procedure OnKzThradGetMaxProgress(Sender: TObject;AMaxProgress:Integer);
    procedure OnKzThradGetOneProgress(Sender: TObject;AOneProgress:Integer);
    procedure OnKzThradGetTxtProgress(Sender: TObject;ATxtProgress:string);
    procedure OnKzThradGetMsgProgress(Sender: TObject;AMsgProgress:string;AVarProgress:array of Variant);
    procedure OnTerminate(Sender:TObject);
  end;

var
  Form1: TForm1;

implementation

uses
  Thrad_WakeDemo;

{$R *.dfm}

procedure TForm1.Btnv_CallClick(Sender: TObject);
var
  I:Integer;
begin
  for I := 1 to 10 do
  begin
    CallThradWakeDemo(I);
  end;
end;

procedure TForm1.CallThradWakeDemo(aDemoIndx: Integer);
var
  cThrad:TThradWakeMemo;
begin
  cThrad := TThradWakeMemo.Create(True);
  cThrad.FCSInData := self.FCSInData;
  cThrad.FDemoIndx := aDemoIndx;
  cThrad.FRealGrid := self.Grid_1;

  cThrad.OnKzThradGetMaxProgress:=OnKzThradGetMaxProgress;
  cThrad.OnKzThradGetOneProgress:=OnKzThradGetOneProgress;
  cThrad.OnKzThradGetTxtProgress:=OnKzThradGetTxtProgress;

  cThrad.OnKzThradGetMsgProgress:=OnKzThradGetMsgProgress;
  cThrad.OnTerminate            :=OnTerminate;
  cThrad.FreeOnTerminate        :=True;

  cThrad.Resume;
end;

procedure TForm1.OnKzThradGetMaxProgress(Sender: TObject;
  AMaxProgress: Integer);
begin

end;

procedure TForm1.OnKzThradGetMsgProgress(Sender: TObject; AMsgProgress: string;
  AVarProgress: array of Variant);
begin

end;

procedure TForm1.OnKzThradGetOneProgress(Sender: TObject;
  AOneProgress: Integer);
begin

end;

procedure TForm1.OnKzThradGetTxtProgress(Sender: TObject; ATxtProgress: string);
begin
  Memo_Main.Lines.Add(ATxtProgress);
end;

procedure TForm1.OnTerminate(Sender: TObject);
begin

end;

procedure TForm1.SetComboItems;
begin
  inherited;

end;

procedure TForm1.SetCommParams;
begin
  inherited;

end;

procedure TForm1.SetGridParams;
begin
  inherited;

end;

procedure TForm1.SetInitialize;
begin
  FCSInData := TCriticalSection.Create;
  inherited;

end;

procedure TForm1.TryFreeAndNil;
begin
  inherited;
  if FCSInData <> nil then FreeAndNil(FCSInDATA);
end;

end.
